package com.robot.console.core;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ClientCommonParam
{
	public static String _FILE_()
	{
		StackTraceElement stackTraces[] = (new Throwable()).getStackTrace();
		return stackTraces[1].getFileName();
	}

	public static String _FILE_LINE_FUNC_()
	{
		StackTraceElement stackTraces[] = (new Throwable()).getStackTrace();
		StringBuffer strBuffer = new StringBuffer("[");
		strBuffer.append(stackTraces[1].getFileName()).append("|");
		strBuffer.append(stackTraces[1].getLineNumber()).append("|");
		strBuffer.append(stackTraces[1].getMethodName()).append("]");
		strBuffer.append(stackTraces[1].getClassName()).append(".");
		return strBuffer.toString();
	}

	public static String _FUNC_()
	{
		StackTraceElement stackTraces[] = (new Throwable()).getStackTrace();
		return stackTraces[1].getMethodName();
	}

	public static int _LINE_()
	{
		StackTraceElement stackTraces[] = (new Throwable()).getStackTrace();
		return stackTraces[1].getLineNumber();
	}

	public static String _TIME_()
	{
		Date now = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
		return sdf.format(now);
	}

	/**
	 * @param logString
	 */
	public static String prepareLogString(String logString)
	{
		String result = "||=====|| : " + _TIME_() + " : " + logString;
		return result;
	}

	public static String prepareLogString(String logString, String file, String line)
	{
		String result = "||=====|| : " + _TIME_() + " : " + "file:" + file + " line:" + line + " content:"
				+ logString;
		return result;
	}

	public static void printInputLine()
	{
		System.out.println("||=====|| : " + _TIME_() + " : ");
	}

	public static void printLogBack(String string)
	{
		String logString = prepareLogString(string);
		System.out.println(logString);
	}

	public static void printLogBack(String string, String file, String line)
	{
		String logString = prepareLogString(string, file, line);
		System.out.println(logString);
	}
}
